package com.mybatiscore.Mapper;

import com.mybatiscore.POJO.Student;
import org.apache.ibatis.annotations.MapKey;
import org.apache.ibatis.annotations.Param;

import java.util.*;

public interface StudentMapper {
    /*
    一、参数
     */
    //简单参数
    List<Student> selectById(Long id);

    List<Student> selectByName(String name);
    List<Student> selectByBirth(Date birth);
    List<Student> selectBySex(Character sex);

    //Map
    int insertMap(Map<String, Object> map);

    //POJO
    int insertPOJO(Student student);

    //多参数
    List<Student> selectNameSex(String name,Character sex);

    //Param
    List<Student> selectNameSex1(@Param("name") String name,@Param("sex") Character sex);

    /*
    二、查询
     */
    //返回单个POJO
    Student selectById1(Long id);

    //返回多个POJO
    List<Student> selectAll();

    //模糊查询
    List<Student> selectNameLike(String name);

    //返回单个map
    @MapKey("id")
    Map<String,Object> selectByIdMap(Long id);

    //返回多个Map
    @MapKey("id")
    List<Map<String,Object>> selectListMap();

    //Map<String,Map>
    @MapKey("id")
    Map<Long,Map<String,Object>> selectMapAll();

    //resultMap进行结果映射
    List<Student> selectAllresultMap();

    //返回记录条数
    Long sselectShu();

    /*
      三.动态sql
     */

    //if
    List<Student> selectByIf(@Param("name") String name,@Param("sex") Character sex);

    //where
    List<Student> selectByWhere(@Param("name") String name,@Param("sex") Character sex);

    //trim
    List<Student> selectByTrim(@Param("name") String name,@Param("sex") Character sex);

    //set
    void updateSet(@Param("id") Long id,@Param("sex") Character sex,@Param("heightT") Double heigthT);

    //choose_when_otherwise
    List<Student> selectChoose(@Param("age") Integer age,@Param("heightT") Double heightT,@Param("sex") Character sex);

    //foreach
    //批量删除
    int deleteByIds(@Param("ids") Long[] ids);

    //批量插入
    int insertByIds(@Param("lists") List<Student> lists);

}

